##########################################
## Copyright 2012-2013 Ceruti Francesco
##
##
## This file is part of LiSP (Linux Show Player).
##
## LiSP (Linux Show Player) is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## LiSP (Linux Show Player) is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with LiSP (Linux Show Player).  If not, see <http://www.gnu.org/licenses/>.
##########################################

import subprocess
import re
import hashlib


def createGradient(color_1, color_2='rgba(255, 255, 255, 255)'):
    return 'qlineargradient(spread:pad, x1:1, y1:1, x2:1, y2:0, stop:0 ' + color_1 + ', stop:1 ' + color_2 + ');'


def systemVolume():
    return re.findall('[0-9]{0,3}%', subprocess.getoutput('amixer sget Master'))[0]


def setSystemVolume(volume):
    subprocess.getoutput('amixer sset Master ' + str(volume))


def md5sum(filename):
    md5 = hashlib.md5()
    with open(filename, 'rb') as f:
        for chunk in iter(lambda: f.read(128 * md5.block_size), b''):
            md5.update(chunk)
    return md5.hexdigest()


class Clipboard:
    clip = None


class Flags:
    flags = {}
